<?php

namespace common\model;

use think\model\RelationModel;

class TaskLibraryViewConfigModel extends RelationModel
{
    //自动完成
    protected $_auto = [
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['updated_by', 'fill_created_by', self::MODEL_UPDATE, 'function'],
        ['updated', 'time', self::MODEL_UPDATE, 'function'],
        ['config', 'json_encode', self::EXISTS_VALIDATE, 'function'],
    ];

    /**
     * 获取器：配置
     * @param $value
     * @return array|mixed
     */
    public function getConfigAttr($value)
    {
        if (!empty($value)) {
            return json_decode($value, true);
        }
        return [];
    }
}
